$(function () {
    $('#page').load('page.html');
})
var dailyData;
function FindAll() {
    let da={
        userName:$.trim($("#userName").val()),
        startSubmissionDate:$.trim($("#startSubmissionDate").val()),
        endSubmissionDate:$.trim($("#endSubmissionDate").val()),
        major:$.trim($("#major").val()),
        coach:$.trim($("#coach").val()),
        supervision:$.trim($("#supervision").val()),
        state:$.trim($("#state").val()),
        pageSize:$("#pageSize").val(),
        pageNum:$("#pageNum").val(),
    }
    let data=myAjax("/daily/dailyFindAll",da,"post");
    dailyData=data.data.list;
    $("#pageCount").text(data.data.total);
    data=data.data.list;
    let html='';
    for (let i=0 ;i<data.length; i++){
        html +='        <tr>\n' +
            '            <td>'+data[i].id+'</td>\n' +
            '            <td>'+data[i].dailyType+'</td>\n' +
            '            <td>'+data[i].userName+'</td>\n' +
            '            <td>'+data[i].submissionDate+'</td>\n' +
            '            <td>'+data[i].major+'</td>\n' +
            '            <td>'+data[i].coach+'</td>\n' +
            '            <td>'+data[i].supervision+'</td>\n' +
            '            <td><div class="biaos">'+data[i].learningContent+'</div></td>\n' +
            '            <td><div class="biaos">'+data[i].harvest+'</div></td>\n' +
            '            <td><div class="biaos">'+data[i].insufficient+'</div></td>\n' +
            '            <td><div class="biaos">'+data[i].opinion+'</div></td>\n' +
            '            <td><input type="button" value="查看" onclick="coachCheckDailyById('+data[i].id+')"><input type="button" value="导出日报" onclick="exportDaily('+i+')"></td>\n' +
            '        </tr>';
    }
    $("#dailyFandAll").html(html);
}

function coachCheckDailyById(id) {
    let da={
        state:2,
        id:id
    }
    let data=myAjax("/daily/dailyUpdateToRead",da,"post");
    if (data.code==200){
        localStorage.removeItem("coachCheckDailyById");
        localStorage.setItem("coachCheckDailyById",id);
        $("#middle-reght").load("daily/coachCheckDaily.html");
    }
}

//导出日报
function exportDaily(i) {
    let da={
        userName:dailyData[i].userName,
        submissionDate:dailyData[i].submissionDate,
        major:dailyData[i].major,
        coach:dailyData[i].coach,
        supervision:dailyData[i].supervision,
        learningContent:dailyData[i].learningContent,
        harvest:dailyData[i].harvest,
        insufficient:dailyData[i].insufficient,
        opinion:dailyData[i].opinion,
    }
    let data=myAjax("/daily/dailyToWorld",da,"post");
    data=data.code;
    if (data==200){
        alert("导出成功")
    }else if (data==500){
        alert("导出失败")
    }
}
